<?php

namespace ChanTienGioi\Backend\Models;

class CtgUserAdmin extends \Phalcon\Mvc\Model
{

    /**
     *
     * @var integer
     */
    public $uaid;

    /**
     *
     * @var string
     */
    public $ua_name;

    /**
     *
     * @var string
     */
    public $ua_secret;

    /**
     *
     * @var string
     */
    public $ua_nickname;

    /**
     *
     * @var string
     */
    public $ua_last_login;

    /**
     *
     * @var string
     */
    public $ua_permission;

    /**
     * Independent Column Mapping.
     */
    public function columnMap()
    {
        return array(
            'uaid'          => 'uaid',
            'ua_name'       => 'ua_name',
            'ua_secret'     => 'ua_secret',
            'ua_nickname'   => 'ua_nickname',
            'ua_last_login' => 'ua_last_login',
            'ua_permission' => 'ua_permission'
        );
    }

    static public function getUserByuserNameAndPassword($username, $password)
    {
        return self::findFirst(
                        array(
                            "ua_name = :username: AND ua_secret = :password:",
                            "bind" => array(
                                "username" => $username,
                                "password" => md5($password)
                            )
                        )
        )->toArray();
    }

}
